package com.gdc.cloud.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * Description: 接收消息 监听服务
 * @author: gdc
 * @date: 2021/2/3
 * @version 1.0
 */
@EnableBinding(Sink.class)
@Component
public class ReceiverMessageListenerService {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void input(Message<String> message){
        System.out.println("消费者 2 号，端口：" + serverPort + ",接收的消息为：" + message.getPayload());
    }
}
